<template>
  <div id="comment-info">
    <div v-if="Object.keys(commentInfo).length !== 0" class="comment-info">
      <div class="info-header">
        <div class="header-title">用户评价</div>
        <div class="header-more">更多<i class="arrow-right"></i></div>
      </div>
      <div class="info-user">
        <img :src="commentInfo.user.avatar" alt="" />
        <span>{{ commentInfo.user.uname }}</span>
      </div>
      <div class="info-detail">
        <p>
          {{ commentInfo.content }}
        </p>
        <div class="info-other">
          <span class="date"
            >{{ commentInfo.created | showDate }} &nbsp;&nbsp;</span
          >
          <span>{{ commentInfo.style }}</span>
        </div>
      </div>
      <div class="info-imgs">
        <img
          :src="item"
          v-for="(item, index) in commentInfo.images"
          :key="index"
          alt=""
        />
      </div>
    </div>
  </div>
</template>

<script>
import { formatDate } from "../../../common/utils";
export default {
  props: {
    commentInfo: {
      type: Object,
    },
    created() {},
  },
  filters: {
    showDate(value) {
      // 将时间戳转换为date对象
      const date = new Date(value * 1000);
      // 将date对象进行格式化
      return formatDate(date, "yyyy-MM-dd");
    },
  },
};
</script>

<style lang="less" scoped>
#comment-info {
  padding: 10px 10px;
  border-top: 10px solid #f1f3f4;

  .comment-info {
    .info-header {
      display: flex;
      justify-content: space-between;
      line-height: 50px;
      border-bottom: 3px solid #f1f3f4;
    }
    .info-user {
      display: flex;
      align-items: center;
      padding: 10px;
      color: black;
      img {
        width: 50px;
        height: 50px;
        margin: 0 10px 0 -10px;
        border-radius: 50%;
      }
    }
    .info-detail {
      p {
        line-height: 26px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .info-other {
        margin: 10px 0;
        font-size: 14px;
        color: #a1869a;
      }
    }
  }
}
</style>